home *** CD-ROM | disk | FTP | other *** search
/ Aminet 45 / Aminet 45 (2001)(GTI - Schatztruhe)[!][Oct 2001].iso / Aminet / game / role / ldmud-3.2-bin.lha / mud / doc / LPC / closures-abstract < prev    next >
Text File  |  2001-04-06  |  3KB  |  79 lines

  1. Procedural elements:
  2. ====================
  3.  
  4. definition of terms:
  5.   <block>     : zero or more values to be evaluated.
  6.   <test>      : one value to be evaluated as branch or loop condition.
  7.   <result>    : one value to be evaluated at the end of the execution of
  8.                 the form; the value is returned.
  9.   <lvalue>    : local variable/parameter, global variable, or an indexed
  10.                 lvalue.
  11.   <expression>: one value to be evaluated.
  12.   <integer>   : an integer constant
  13.   <string>    : a string constant, or 0.
  14. used EBNF operators:
  15. { }        iteration
  16. [ ]        option
  17. |        alternative
  18.  
  19. forms:
  20.   ({#', <body> <result>})
  21.   ({#'? { <test> <result> } [ <result> ] })
  22.   ({#'?! { <test> <result> } [ <result> ] })
  23.   ({#'&& { test } })
  24.   ({#'|| { test } })
  25.   ({#'while <test> <result> <body>...})        loop while test evaluates non-zero.
  26.   ({#'do <body> <test> <result>})        loop till test evaluates zero.
  27.   ({#'foreach <var> <expr> <body>...})        loop over all values of <expr>.
  28.   ({#'foreach ({ <var>...<var> }) <expr> <body>...})
  29.   ({#'= { <lvalue> <value> } })                assignment
  30.                                         other assignment operators work too.
  31.   case_label: <integer> | <string> | #'default
  32.   generalized_case_label: case_label | <integer> #'.. <integer>
  33.   case_label_list: case_label | ({ { generalized_case_label } })
  34.   case_delimiter: #', | #'break
  35.   ({#'switch <expression> { case_label_list <result> case_delimiter } })
  36.         Evaluate expression, then evaluate the result form labeled with
  37.         the value equal to the value evaluated from expression.
  38.         If no matching label exists, the value of #'switch is 0.
  39.   ({#'catch, <body> [ 'nolog ] })
  40.         Evaluates the <body> and catches any runtime error. If the symbol
  41.         'nolog is also given, a caught error is not logged.
  42.  
  43.  
  44. lisp similars:
  45.   #',                progn
  46.   #'?                cond
  47.   #'&&                and
  48.   #'||                or
  49.   #'while        do         /* but lisp has more syntactic candy here */
  50.   #'=                setq
  51.  
  52. A parameter / local variable 'foo' is referenced as 'foo , a global
  53. variable as ({#'foo}) . In lvalue positions (assignment), you need not
  54. enclose global variable closures in arrays.
  55.  
  56. Call by reference parameters are given with ({#'&, <lvalue>})
  57.  
  58. Some special efuns:
  59. #'[                indexing
  60. #'[<                indexing from the end
  61. #'negate        unary -
  62.  
  63. Unbound lambda closures
  64. =======================
  65.  
  66. These closures are not bound to any object. They are created with the efun
  67. unbound_lambda() . They cannot contain references to global variables, and
  68. all lfun closures are inserted as is, since there is no native object for
  69. this closure.
  70. You can bind and rebind unbound lambda closures to an object with efun
  71. bind_lambda() You need to bind it before it can be called. Ordinary objects
  72. can obly bind to themselves, binding to other objects causes a privilege
  73. violation().
  74. The point is that previous_object for calls done from inside the closure
  75. will reflect the object doing bind_lambda(), and all object / uid based
  76. security will also refer to this object.
  77.  
  78.  
  79.